home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / fe1.zip / FE.H < prev    next >
C/C++ Source or Header  |  1992-02-07  |  3KB  |  132 lines

  1. #include <stddef.h>
  2. #include <msmouse.h>
  3. #include <fg.h>
  4.  
  5. #ifndef __FE_H
  6. #define __FE_H
  7.  
  8. #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
  9. #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
  10.  
  11. class win ;
  12.  
  13. typedef void ( win :: *eventscript_t )() ;
  14.  
  15. class boxes {
  16.  
  17.     public :
  18.         boxes ( size_t ) ;
  19.  
  20.         ~boxes () {
  21.             delete comd ;
  22.             delete comdscripts ;
  23.         }
  24.  
  25.         void add_script ( fg_pbox_t, eventscript_t ) ;
  26.  
  27.         void translate_script ( win *, fg_coord_t, fg_coord_t ) ;
  28.  
  29.     private :
  30.         fg_pbox_t *comd ;
  31.         eventscript_t *comdscripts ;
  32.         size_t size ;
  33.         size_t point ;
  34. } ;
  35.  
  36. class keyboard {
  37.  
  38.     public :
  39.         keyboard ( size_t ) ;
  40.  
  41.         ~keyboard () {
  42.             delete comd ;
  43.             delete comdscripts ;
  44.         }
  45.  
  46.         void add_script ( char, eventscript_t ) ;
  47.  
  48.         void translate_script ( win *, char ) ;
  49.  
  50.     private :
  51.         char *comd ;
  52.         eventscript_t *comdscripts ;
  53.         size_t size ;
  54.         size_t point ;
  55. } ;
  56.  
  57. class win {
  58.  
  59.     public :
  60.         win ( fg_coord_t _x, fg_coord_t _y, fg_coord_t _w,
  61.             fg_coord_t _h, fg_color_t _fg, fg_color_t _bg,
  62.             win *_p, size_t _ks, size_t _bs ) :
  63.             x( _x ), y( _y ), height( _h ), width( _w ),
  64.             fgc( _fg ), bgc( _bg ), parent( _p ), quit( 0 ),
  65.             activate_key( '\x0' ) {
  66.  
  67.             if ( parent ) {
  68.                 x += parent->x ;
  69.                 y += parent->y ;
  70.             }
  71.  
  72.             fg_make_box( winbox, x, y, x + width - 1,
  73.                 y + height - 1 ) ;
  74.             kbd = new keyboard( _ks ) ;
  75.             box = new boxes( _bs ) ;
  76.         }
  77.         ~win () { delete kbd ; delete box ; }
  78.             
  79.         virtual void expose () = 0 ;
  80.         virtual void focus () = 0 ;
  81.         virtual void destroy () = 0 ;
  82.  
  83.         void cls () {
  84.             fg_fillbox( bgc, FG_MODE_SET, ~0, winbox ) ;
  85.         }
  86.         void clear () {
  87.             fg_fillbox( FG_BLACK, FG_MODE_SET, ~0, winbox ) ;
  88.         }
  89.         void focus_loop ( win * ) ;
  90.         void expose_parent () { if ( parent ) parent->expose() ; }
  91.  
  92.         void add_script ( fg_box_t b, eventscript_t s ) {
  93.             box->add_script( b, s ) ;
  94.         }
  95.         void add_script ( char k, eventscript_t s ) {
  96.             kbd->add_script( k, s ) ;
  97.         }
  98.  
  99.     protected :
  100.         fg_coord_t x, y, height, width ;
  101.         fg_color_t fgc, bgc ;
  102.         win *parent ;
  103.         fg_box_t winbox ;
  104.         keyboard *kbd ;
  105.         boxes *box ;
  106.         int quit ;
  107.         char activate_key ;
  108. } ;
  109.  
  110. class editmap ;
  111.  
  112. class menu : public win {
  113.  
  114.         friend editmap ;
  115.  
  116.     public :
  117.         menu ( fg_coord_t, fg_coord_t, size_t, size_t, win * ) ;
  118.         ~menu () { delete i_names ; }
  119.  
  120.         void add_item ( char, char *, eventscript_t ) ;
  121.  
  122.         void expose () ;
  123.         void focus () ;
  124.         void destroy () ;
  125.  
  126.     private :
  127.         char **i_names ;
  128.         size_t point, size ;
  129. } ;
  130.  
  131. #endif
  132.